<?php 
   
include_once("public/head.php");
$name = isset($_SESSION['uname'])?$_SESSION['uname']:'';
@mysql_connect('localhost', 'root', 'root');
mysql_select_db('blog');
mysql_set_charset('utf8');

$page = isset($_GET['p'])?$_GET['p']:1;
$num = 5;
$py = ($page-1)*$num;

$sql = "select * from `message` limit $py,$num";
$res = mysql_query($sql);
while ($rows = mysql_fetch_assoc($res)) {
    $arr[] = $rows;
}


$sql_all ="select * from `message`";
$res_all = mysql_query($sql_all);
$count = mysql_num_rows($res_all);//总条数
$page_all = ceil($count/$num) ;//总页数

$prev = $page -1;
if ($prev<1) {
  $prev = 1;
}
$next = $page +1;
if ($next>$page_all) {
  $next = $page_all;
}
 ?>
  <div class="jztop"></div>
  <div class="container">
    <div class="bloglist f_l">
    内容主体
    <form action="addmessage.php" method="post" enctype="multipart/form-data">
     <table width="100%">
        <script id="container" name="content" type="text/plain" style="width: 600px">                 
        </script>         
     </table>
     
     <!-- 配置文件 -->
                    <script type="text/javascript" src="/public/utf8-php/ueditor.config.js"></script>
                    <!-- 编辑器源码文件 -->
                    <script type="text/javascript" src="/public/utf8-php/ueditor.all.js"></script>
                    <!-- 实例化编辑器 -->
                    <script type="text/javascript">
                        var ue = UE.getEditor('container',{
                          toolbars:[
                          ['emotion']
                          ]
                        });
                          
                   </script>
                   <input type="hidden" name="uname" value="<?php echo $name ?>">
                <input class="btn btn-primary btn6 mr10" value="畅言一下" type="submit" style="background: #E74851 ;color: #fff;height:35px;width:80px;border-radius: 15px;">
    </form>
    <ul>
    <?php 

    foreach ($arr as $v) {
      echo'<li>用户名：'.$v['name'].'</li>
      <li>留言：'.$v['message'].'</li>
      <li>留言时间：'.date("Y-m-d h:i:s",$v['ctime']).'</li>
      <li style="color: red;text-align: center;">~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</li>';
    } 
    echo
    "<a href=message.php?p=$prev>上一页</a>,
    <a href=message.php?p=$next>下一页</a>";
     ?>
    </ul>
    </div>
    <div class="r_box f_r">
      <div class="tuwen">
        <h3 class="tit">关注我</h3>
        <ul>
          <li>网名:Fade | 褪色</li>
          <li>籍贯：湖北-仙桃</li>
          <li>现居：湖北-武汉</li>
          <li>职业：网站制作 后台维护</li>
          <li>个人微信号：zx110119120</li>
          <li>微信请备注：博客</li>
        </ul>
        <p><a target="_blank" href="http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=hbC1trawtbC2s8X09Kvm6ug" style="text-decoration:none;"><img src="http://rescdn.qqmail.com/zh_CN/htmledition/images/function/qm_open/ico_mailme_21.png"/></a></p>
      </div>
    
      <div class="ad"> <img src="public/images/001.jpg"> </div>
    </div>
  </div>
  <!-- container代码 结束 -->
<?php 
include_once("public/after.php");
 ?>